package com.ztesoft.bss.base.util;

import com.iwhalecloud.bss.kite.manager.enums.ActionType;
import com.iwhalecloud.bss.kite.manager.enums.InstType;
import com.iwhalecloud.bss.kite.manager.inst.KiteProdInstFunc;
import com.iwhalecloud.bss.kite.manager.inst.KiteSceneInst;
import com.iwhalecloud.bss.kite.manager.inst.graph.IInstRelGraph;
import com.iwhalecloud.bss.kite.manager.inst.graph.impl.InstVertex;
import com.iwhalecloud.bss.kite.manager.scene.util.InstUtils;
import com.iwhalecloud.bss.kite.manager.scene.util.SceneInstUtils;
import com.iwhalecloud.bss.kite.manager.transaction.TransactionContext;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;

/**
 * 场景实例工具类
 */
public class LocalSceneInstUtils {

    public static List<KiteProdInstFunc> listProdInstFuncs(String sceneInstId) {
        List<InstVertex> prodInstFuncVertexs = new ArrayList();
        KiteSceneInst sceneInst = TransactionContext.getContainer().getSceneInst(sceneInstId);
        String custId = SceneInstUtils.getCustId(sceneInst);
        IInstRelGraph sceneInstRelGraph = SceneInstUtils.getSceneInstRelGraph(sceneInst);
        List<InstVertex> instVertexs = sceneInstRelGraph.listVertexs();
        Iterator var8 = instVertexs.iterator();

        while(var8.hasNext()) {
            InstVertex instVertex = (InstVertex)var8.next();
            if (!Objects.equals(ActionType.X, instVertex.getActionType()) && Objects.equals(InstType.PROD_INST_FUNC, instVertex.getInstType())) {
                prodInstFuncVertexs.add(instVertex);
            }
        }
        return InstUtils.transformInsts(custId, prodInstFuncVertexs);
    }
}
